/**
* 左边菜单
*/ 
<template>
  <el-menu
    default-active="2"
    :collapse="collapsed"
    collapse-transition
    router
    :default-active="$route.path"
    unique-opened
    class="el-menu-vertical-demo"
    background-color="#0F76F1"
    text-color="#fff"
    active-text-color="#ffd04b"
  >
    <div class="logobox">
      <div>荣祥超市</div>
      <!-- <img class="logoimg" src="../assets/img/logo.png" alt="" /> -->
    </div>
    <el-submenu
      v-for="menu in allmenu"
      :key="menu.menuid"
      :index="menu.menuname"
    >
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{ menu.menuname }}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item
          v-for="chmenu in menu.menus"
          :index="'/' + chmenu.url"
          :key="chmenu.menuid"
        >
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{ chmenu.menuname }}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
export default {
  name: "leftnav",
  data() {
    return {
      collapsed: false,
      allmenu: [],
    };
  },
  // 创建完毕状态(里面是操作)
  created() {
    // 获取图形验证码
    let res = {
      success: true,
      data: [
        // {
        //   menuid: 0,
        //   icon: 'li-icon-xiangmuguanli',
        //   menuname: '首页',
        //   hasThird: null,
        //   url: 'index',
        //   menus: null
        // },
        {
          menuid: 1,
          icon: "li-icon-xiangmuguanli",
          menuname: "零售管理",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 11,
              icon: "icon-cat-skuQuery",
              menuname: "零售出库",
              hasThird: "N",
              url: "goods/Goods",
              menus: null,
            },
            {
              menuid: 12,
              icon: "icon-news-manage",
              menuname: "零售退货",
              hasThird: "N",
              url: "goods/center",
              menus: null,
            },
          ],
        },
        {
          menuid: 2,
          icon: "li-icon-dingdanguanli",
          menuname: "采购管理",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 21,
              icon: "icon-order-manage",
              menuname: "采购订单",
              hasThird: "N",
              url: "pay/Order",
              menus: null,
            },
            {
              menuid: 22,
              icon: "icon-order-manage",
              menuname: "采购入库",
              hasThird: "N",
              url: "pay/PurchaseDelivery",
              menus: null,
            },
            {
              menuid: 23,
              icon: "icon-order-manage",
              menuname: "采购退货",
              hasThird: "N",
              url: "pay/PurchaseRefund",
              menus: null,
            },
          ],
        },
        // {
        //   menuid: 3,
        //   icon: "li-icon-xitongguanli",
        //   menuname: "销售管理",
        //   hasThird: null,
        //   url: null,
        //   menus: [
        //     {
        //       menuid: 31,
        //       icon: "icon-cus-manage",
        //       menuname: "销售订单",
        //       hasThird: "N",
        //       url: "system/user",
        //       menus: null,
        //     },
        //     {
        //       menuid: 32,
        //       icon: 'icon-cms-manage',
        //       menuname: '销售入库',
        //       hasThird: 'N',
        //       url: 'system/Module',
        //       menus: null
        //     },
        //     {
        //       menuid: 33,
        //       icon: "icon-news-manage",
        //       menuname: "销售出库",
        //       hasThird: "N",
        //       url: "system/Role",
        //       menus: null,
        //     },
        //   ],
        // },
        // {
        //   menuid: 4,
        //   icon: "li-icon-shangchengxitongtubiaozitihuayuanwenjian91",
        //   menuname: "仓库管理",
        //   hasThird: null,
        //   url: null,
        //   menus: [
        //     {
        //       menuid: 41,
        //       icon: "icon-provider-manage",
        //       menuname: "其他入库",
        //       hasThird: "N",
        //       url: "system/Dept",
        //       menus: null,
        //     },
        //      {
        //       menuid: 42,
        //       icon: "icon-provider-manage",
        //       menuname: "其他出库",
        //       hasThird: "N",
        //       url: "system/OtherDelivery",
        //       menus: null,
        //     },
        //   ],
        // },
        // {
        //   menuid: 5,
        //   icon: "li-icon-shangchengxitongtubiaozitihuayuanwenjian91",
        //   menuname: "财务管理",
        //   hasThird: null,
        //   url: null,
        //   menus: [
        //     {
        //       menuid: 51,
        //       icon: "icon-provider-manage",
        //       menuname: "收入单",
        //       hasThird: "N",
        //       url: "machine/MachineConfig",
        //       menus: null,
        //     },
        //     {
        //       menuid: 52,
        //       icon: "icon-provider-manage",
        //       menuname: "支出单",
        //       hasThird: "N",
        //       url: "machine/PaymentDom",
        //       menus: null,
        //     },
        //     {
        //       menuid: 53,
        //       icon: "icon-provider-manage",
        //       menuname: "收款单",
        //       hasThird: "N",
        //       url: "machine/ReceiptDom",
        //       menus: null,
        //     },
        //     {
        //       menuid: 54,
        //       icon: "icon-provider-manage",
        //       menuname: "付款单",
        //       hasThird: "N",
        //       url: "machine/PayingDom",
        //       menus: null,
        //     },
        //     {
        //       menuid: 55,
        //       icon: "icon-provider-manage",
        //       menuname: "转账单",
        //       hasThird: "N",
        //       url: "machine/TransferDom",
        //       menus: null,
        //     },
        //     {
        //       menuid: 56,
        //       icon: "icon-provider-manage",
        //       menuname: "收预付款",
        //       hasThird: "N",
        //       url: "machine/PrePayment",
        //       menus: null,
        //     },
        //   ],
        // },
        {
          menuid: 6,
          icon: "li-icon-dingdanguanli",
          menuname: "报表查询",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 61,
              icon: "icon-order-manage",
              menuname: "商品库存",
              hasThird: "N",
              url: "charts/statistics",
              menus: null,
            },
            {
              menuid: 62,
              icon: "icon-provider-manage",
              menuname: "账户统计",
              hasThird: "N",
              url: "pay/Config",
              menus: null,
            },
            {
              menuid: 63,
              icon: "icon-cms-manage",
              menuname: "采购统计",
              hasThird: "N",
              url: "system/Permission",
              menus: null,
            },
            {
              menuid: 64,
              icon: "icon-cus-manage",
              menuname: "入库明细",
              hasThird: "N",
              url: "system/user",
              menus: null,
            },
            {
              menuid: 65,
              icon: "icon-cms-manage",
              menuname: "入库汇总",
              hasThird: "N",
              url: "system/Module",
              menus: null,
            },
            {
              menuid: 66,
              icon: "icon-news-manage",
              menuname: "存库预警",
              hasThird: "N",
              url: "system/Role",
              menus: null,
            },
          ],
        },
        {
          menuid: 7,
          icon: "li-icon-xiangmuguanli",
          menuname: "商品管理",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 71,
              icon: "li-icon-xiangmuguanli",
              menuname: "商品类别",
              hasThird: "N",
              url: "product/ProductClass",
              menus: null,
            },
            {
              menuid: 72,
              icon: "li-icon-xiangmuguanli",
              menuname: "商品信息",
              hasThird: "N",
              url: "product/ProductMessage",
              menus: null,
            },
          ],
        },
        {
          menuid: 8,
          icon: "li-icon-shangchengxitongtubiaozitihuayuanwenjian91",
          menuname: "基本资料",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 81,
              icon: "icon-provider-manage",
              menuname: "收支项目",
              hasThird: "N",
              url: "BasicInformation/SzProject",
              menus: null,
            },
            {
              menuid: 82,
              icon: "icon-provider-manage",
              menuname: "结算账户",
              hasThird: "N",
              url: "BasicInformation/CloseAccount",
              menus: null,
            },
            {
              menuid: 83,
              icon: "icon-provider-manage",
              menuname: "供应商信息",
              hasThird: "N",
              url: "BasicInformation/supplieMessage",
              menus: null,
            },
            {
              menuid: 84,
              icon: "icon-provider-manage",
              menuname: "客户信息",
              hasThird: "N",
              url: "BasicInformation/clientMessage",
              menus: null,
            },
            {
              menuid: 85,
              icon: "icon-provider-manage",
              menuname: "仓库信息",
              hasThird: "N",
              url: "BasicInformation/storeMessage",
              menus: null,
            },
          ],
        },
        {
          menuid: 9,
          icon: "li-icon-xiangmuguanli",
          menuname: "系统管理",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 91,
              icon: "li-icon-xiangmuguanli",
              menuname: "角色管理",
              hasThird: "N",
              url: "SystemAdmin/RoleAdmin",
              menus: null,
            },
            {
              menuid: 92,
              icon: "li-icon-xiangmuguanli",
              menuname: "用户管理",
              hasThird: "N",
              url: "SystemAdmin/UserAdmin",
              menus: null,
            },
          ],
        },
      ],
      msg: "success",
    };
    this.allmenu = res.data;

    // menu(localStorage.getItem('logintoken'))
    //   .then(res => {
    //     console.log(JSON.stringify(res))
    //     if (res.success) {
    //       this.allmenu = res.data
    //     } else {
    //       this.$message.error(res.msg)
    //       return false
    //     }
    //   })
    //   .catch(err => {
    //     this.$message.error('菜单加载失败，请稍后再试！')
    //   })
    // 监听
    this.$root.Bus.$on("toggle", (value) => {
      this.collapsed = !value;
    });
  },
};
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  height: 40px;
  /* line-height: 40px; */
  color: white;
  font-size: 25px;
  /* text-align: center; */
  padding: 20px 30px;
}
.logoimg {
  height: 40px;
}
</style>